<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\admin\model;

class ShopType extends \app\BaseModel
{
    protected $name = "longbing_card_shop_type";
    protected $schema = [];
    protected $resultSetType = "array";
    public function __construct()
    {
        parent::__construct();
    }
    protected static function init()
    {
    }
    public function cateList($dis, $page = 10)
    {
        $data = \think\facade\Db::name($this->name)->where($dis)->paginate($page)->toArray();
        return $this->getTree($data["data"], 0);
    }
    public function getTree($data, $pId)
    {
        $tree = [];
        if(!empty($data)) {
            foreach ($data as $k => $v) {
                if($v["pid"] == $pId) {
                    $v[""] = $this->getTree($data, $v["id"]);
                    $tree[] = $v;
                }
            }
        }
        return $tree;
    }
    public function cateUpdate($dis, $data)
    {
        $data["update_time"] = time();
        $res = \think\facade\Db::name($this->name)->where($dis)->update($data);
        return $res;
    }
    public function cateAdd($data)
    {
        $data["create_time"] = time();
        $res = \think\facade\Db::name($this->name)->insert($data);
        return $res;
    }
    public function cateInfo($dis)
    {
        $data = \think\facade\Db::name($this->name)->where($dis)->find();
        return $data;
    }
    public function catSelect($dis = [])
    {
        $data = \think\facade\Db::name($this->name)->where($dis)->select();
        return $data;
    }
    public function catSortSelect($dis = [])
    {
        $data = \think\facade\Db::name($this->name)->where($dis)->select();
        return $this->getTree($data, 0);
    }
}

?>